<?php
namespace app\controllers\admin;

use app\commands\ErrorMsg;
use app\commands\Helper;
use app\commands\Validator;
use app\Services\admin\SeatService;
use yii\web\Controller;


class SeatController extends Controller
{
    public $req = array();
    public $user = array();

    /**
     * 安全 校验 屏蔽
     * 预处理  权限等等操作处理
     */
    public function beforeAction($action){
        $this->req = Helper::in(array_merge($_POST, $_GET));
        $this->user = Helper::checksign($this->req);
        unset($this->req['token']);
        return true;
    }

    /**
     * 会场管理列表 （占座情况）
     */
    public function actionVenueList(){
        $req = $this->req;
        # 请求参数验证
        $rules = array(
            'roomID'        => "required|integer",
        );
        Validator::validator($req, $rules,ErrorMsg::ERROR_MSG);
        $res = SeatService::getInstance()->getVenueList($req['roomID']);
        Helper::right_out($req,$res);
    }

    /**
     * 踢人
     */
    public function actionKick(){
        $req = $this->req;
        # 请求参数验证
        $rules = array(
            'userID' => "required|integer",
            'roomID' => "required|integer",
            'seatNum'=> "required|alpha_num"
        );
        Validator::validator($req, $rules,ErrorMsg::ERROR_MSG);
        $res = SeatService::getInstance()->kickUser($req['userID'],$req['roomID'],$req['seatNum']);
        Helper::right_out($req,$res);
    }



}
